/**
 * 高级搜索提交表单，并关闭did这个活动窗口 author 熊诗宇
 * 
 * @param o
 *            this
 * @param did
 *            窗口的id
 */
function submitAndClose(o, did) {
	var b = navTabSearch(o);
	$.pdialog.close(did);
	return b;
}

/**
 * 用户管理中高级搜索中的查询框的查找带回，因为input的name不符合dwz的命名规则，所以重写 author 熊诗宇
 * 
 * @param o
 */
function bringBackAndSearhBack(o) {
	$.bringBack(o);
	$("#advancedsearchform").find("input[name='search_EQ_organization.name']")
			.val(o.name);
}

/**
 * 清空搜索条件 author 熊诗宇
 */
function cleanSearch(rel, args) {
	var pName = ["pageNum", "numPerPage", "orderField", "orderDirection"];
	options = {
		targetType : "navTab",
		rel : rel,
		data : args
	};
	var op = $.extend({
				targetType : "navTab",
				rel : "",
				data : {
					pageNum : "",
					numPerPage : "",
					orderField : "",
					orderDirection : ""
				},
				callback : null
			}, options);
	var $parent = op.targetType == "dialog" ? $.pdialog.getCurrent() : navTab
			.getCurrentPanel();
	var form = _getPagerForm($parent, op.data);
	$(form).find("input").each(function() {
				if (!in_array(pName, $(this).attr("name"))) {
					if ($(this).attr("name") == "isSearch") {
						$(this).val("false");
					} else {
						$(this).val("");
					}
				}
			});
	var params = $(form).serializeArray();
	if (form)
		navTab.reload($(form).attr("action"), {
					data : params,
					callback : op.callback
				});
}

/**
 * 判断某个元素是否在数组中
 */
function in_array(array, e) {
	for (var i = 0; i < array.length; i++) {
		if (array[i] == e)
			return true;
	}
	return false;
}
